package com.atguigu.tingshu.album.rpc;


import com.atguigu.tingshu.album.mapper.BaseCategory3Mapper;
import com.atguigu.tingshu.album.service.AlbumInfoService;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.album.service.TrackInfoService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.*;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.vo.album.AlbumStatVo;
import com.atguigu.tingshu.vo.album.TrackListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/albumInfo/rpc")
public class AlbumInfoRpcController {



    @Autowired
    private AlbumInfoService albumInfoService;

    @Autowired
     private BaseCategoryService baseCategoryService;

    @Autowired
    private TrackInfoService trackInfoService;


    @GetMapping("/getAlbumInfoAndTag/{albumId}")
    Result<AlbumInfo> getAlbumInfoAndTag(@PathVariable("albumId") Long albumId){
        AlbumInfo albumInfo = albumInfoService.getAlbumInfo(albumId);
        return Result.ok(albumInfo);
    }

    @GetMapping("/getAlbumInfoCatergoryView/{albumId}")
    Result<BaseCategoryView> getAlbumInfoCatergoryView(@PathVariable("albumId") Long albumId){
        BaseCategoryView baseCategoryView = albumInfoService.getAlbumInfoCatergoryView(albumId);
        return Result.ok(baseCategoryView);
    }


    @GetMapping("/getAlbumStatNum/{albumId}")
    Result<AlbumStatVo> getAlbumStatNum(@PathVariable("albumId") Long albumId){
        AlbumStatVo albumStatVo = albumInfoService.getAlbumStatNum(albumId);
        return Result.ok(albumStatVo);
    }
    @GetMapping("/findTopCategory3ByC1Id/{c1Id}")
    Result<List<BaseCategory3>> findTopCategory3ByC1Id(@PathVariable("c1Id") Long c1Id){
        List<BaseCategory3> baseCategory3List = baseCategoryService.findTopCategory3ByC1Id(c1Id);
        return Result.ok(baseCategory3List);
    }


    @GetMapping("/getAllCategory1")
    Result<List<BaseCategory1>> getAllCategory1(){
        List<BaseCategory1> baseCategory1List = baseCategoryService.getAllCategory1();
        return Result.ok(baseCategory1List);
    }

    @PostMapping("/getTrackListVo")
    Result<List<TrackListVo>> getTrackListVo(@RequestBody List<Long> trackIds){
        List<TrackListVo> trackListVos=trackInfoService.getTrackListVo(trackIds);
        return Result.ok(trackListVos);
    }

    @GetMapping("/checkAndFilterTrackList/{userId}/{itemId}/{trackCount}")
    Result<List<TrackInfo>> checkAndFilterTrackList(@PathVariable("userId") Long userId,
                                              @PathVariable("itemId") Long itemId,
                                              @PathVariable("trackCount") Integer trackCount){

        List<TrackInfo> canPaytrackList= albumInfoService.checkAndFilterTrackList(userId,itemId,trackCount);
        return Result.ok(canPaytrackList);
    }

    @GetMapping("/getTrackInfoByTrackId/{itemId}")
    Result<TrackInfo> getTrackInfoByTrackId(@PathVariable("itemId")  Long itemId){
        TrackInfo trackInfo= albumInfoService.getTrackInfoByTrackId(itemId);
        return Result.ok(trackInfo);
    }
}
